package cn.tedu.sp09.feign;

//远程调用

import cn.tedu.sp01.pojo.Item;
import cn.tedu.web.util.JsonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

//在feign远程接口中指定降级类，即到了降级超时时间，远程调用失败了，会去执行降级类中的代码，趁早给用户一个反馈
@FeignClient(name="item-service",fallback = ItemClientFB.class)
public interface ItemClient {

    //1.远程调用Item服务器的：根据订单ID 查询商品列表
    @GetMapping("/{orderId}")
    JsonResult<List<Item>> getItems(@PathVariable String orderId);


    //2.远程调用ITem服务器的：根据Item集合，减少商品库存
    @PostMapping("/decreaseNumber")
    JsonResult decreaseNumber(@RequestBody List<Item> items);

}
